﻿using System;
using System.Collections.Generic;
using System.Text;

namespace ObjectSync
{
    public sealed class IDManager
    {
        #region SINGLETON
        static readonly IDManager instance = new IDManager();

        // Explicit static constructor to tell C# compiler
        // not to mark type as beforefieldinit
        static IDManager()
        {
        }

        IDManager()
        {
        }

        public static IDManager Instance
        {
            get
            {
                return instance;
            }
        }
        #endregion

        private int NetIds = 1;
        private long RemoteIds = 1;

        /// <summary>
        /// Get the next unused netId number
        /// </summary>
        public int NextNetID
        {
            get
            {
                if (NetIds > 1000000) NetIds = 0;
                return NetIds++;
            }
        }

        /// <summary>
        /// Get the next unused netId number
        /// </summary>
        public long NextRemoteID
        {
            get
            {
                if (RemoteIds > 100000000) RemoteIds = 0;
                return RemoteIds++;
            }
        }


    }
}
